package com.example.diagnodroid.localisation;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

public class ArrowView extends View {
    private Paint   mPaint = new Paint();
    private Path    mPath = new Path();

    public ArrowView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);

        mPath.moveTo(0, -50);
        mPath.lineTo(-20, 60);
        mPath.lineTo(0, 50);
        mPath.lineTo(20, 60);
        mPath.close();
    }

    @Override protected void onDraw(Canvas canvas) {
        Paint paint = mPaint;

        canvas.drawColor(Color.WHITE);

        paint.setAntiAlias(true);
        paint.setColor(Color.BLACK);
        paint.setStyle(Paint.Style.FILL);

        int w = canvas.getWidth();
        int h = canvas.getHeight();
        int cx = w / 2;
        int cy = h / 2;

        canvas.translate(cx, cy);
        if (OrientationActivity.direction != 0) {
            canvas.rotate(-OrientationActivity.direction);
        }
        canvas.drawPath(mPath, mPaint);
    }
}
